<template>
  <div>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="笔记内容">
        <el-input type="textarea" v-model="form.contents" :rows="6"></el-input>
      </el-form-item>
      <el-form-item label="是否公开">
        <el-switch v-model="isOpen"> </el-switch>
      </el-form-item>
      <el-form-item style="text-align: right">
        <el-button type="primary" @click="handleSubmit" size="small"
          >提交</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      isOpen: true,
      form: {
        courseId: '',
        contents: '',
        isOpen: '1', //是否公开（0-不公开，1-公开）
        resId: '', //章节id
        resType: '1', //资源类型（1-章）
        auditStatus: 2, //审核状态1-待审核(默认值)，2-审核通过，3-审核不通过
      },
    }
  },
  mounted() {},
  methods: {
    handleSubmit() {
      let { id, cId } = this.$route.query
      this.form.courseId = id
      this.form.resId = cId
      this.form.isOpen = this.isOpen ? 1 : 0
      this.add()
    },
    async add() {
      await this.$store.dispatch('addSysCourseNotes', this.form)
      this.form = this.$options.data().form
      this.isOpen = true
      this.$bus.$emit('getMyNoteList')
    },
  },
}
</script>
<style scoped lang="scss">
</style>